{% extends "base.html" %}
{% load static %}
{% load post_tags %}

{% block title %}
    <title>首页</title>
{% endblock %}

{% block head_extras %}
<link rel="stylesheet" type="text/css" href="{% static 'post/css/index.css' %}">
<style type="text/css">
    div.jumbotron{
        margin-top: 20px;
        background-color:#A9A9A9;
    }
    .panel-info > .panel-heading{
        background-image:linear-gradient(to bottom, #428bca 0%, #428bca 100%);
    }
    .post-title{
        margin-left: -170px;
    }
    .post-title > h2{
        color:#000000;
    }
    .entry-meta{
        position: relative;
        font-size: 17px;
        left:240px;
    }
    .entry-content{
        font-size: 20px;
    }
    .entry-content >div.read-more{
        margin-left: 325px;
    }
    .panel-title{
        color:#eeeeee;
    }

</style>
{% endblock %}

{% block content %}
<div class="content-body">
    {% block showcase %}
    <div class="container theme-showcase" role="main">
        <div class="jumbotron">
            <h1>欢迎访问长安大学成绩管理系统!</h1>
            <p>您可以在这里查看最新的学校公告，也可以管理自己的成绩和课表，希望您能喜欢.</p>
        </div>
    </div>
    {% endblock %}
    <div class="container">
        <div class="row">
            <main class="col-md-8">
                {% block main %}
                    {% for post in post_list %}
                    <article class="post post-{{ post.pk }}">
                        <header class="entry-headder">
                            <h1 class="entry-meta">
                                <a  href="{{ post.get_absolute_url }}"><div class="post-title"><h2>{{ post.title }}</h2></div></a>
                            </h1>
                            <div class="entry-meta">
                                <span class="post-category">{{ post.category.name }} | </span>
                                <span class="post_date"><time class="entry-date" datetime="{{ post.created_time }}">{{ post.created_time }} | </time></span>
                                <span class="post_author">{{ post.author }}</span>
                            </div>
                        </header>
                        <div class="entry-content clearfix">
                            <p>{{ post.excerpt }}...</p>
                            <br/>
                            <div class="read-more cl-effect-14">
                                <a href="{{ post.get_absolute_url }}" class="more-link">继续阅读<span class="meta-nav">→</span></a>
                            </div>
                        </div>
                    </article>
                    {% empty %}
                        <div class="no-post">暂时还没有发布的公告</div>
                    {% endfor %}

                    {% if is_paginated %}
                    <div class="pagination">
                        {% if page_obj.has_previous %}
                            <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
                        {% endif %}
                        <span class="current">第 {{ paeg_obj.number }} 页 / 共 {{ paginator.num_pages }} 页</span>
                        {% if page_obj.has_next %}
                            <a href="?page={{ page_obj.next_page_number }}">下一页</a>
                        {% endif %}
                    </div>
                    {% endif %}
                {% endblock main %}
            </main>

            <aside class="col-md-4">
                {% block toc %}
                {% endblock toc %}
                <div class="widget widget-recent-posts">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <h3 class="panel-title">最近公告</h3>
                        </div>
                        {% get_recent_posts as recent_post_list %}
                        <div class="list-group">
                            {% for post in recent_post_list %}
                                <a href="{{ post.get_absolute_url }}" class="list-group-item">{{ post.title }}</a>
                            {% empty %}
                            <a class="list-group-item">暂无通告！</a>
                            {% endfor %}
                        </div>
                    </div>
                </div>
                <div class="widget widget-archives">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <h3 class="panel-title">归档</h3>
                        </div>
                        {% archives as date_list %}
                        <div class="list-group">
                            {% for date in date_list %}
                                <a href="{% url 'archives' date.year date.month %}" class="list-group-item">{{ date.year }} 年 {{ date.month }} 月</a>
                            {% empty %}
                            <a class="list-group-item">暂无归档</a>
                            {% endfor %}
                        </div>
                    </div>
                </div>

                <div class="widget widget-category">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <h3 class="panel-title">分类</h3>
                        </div>
                        {% get_categories as category_list %}
                        <div class="list-group">
                            {% for category in category_list %}
                                <a href="{% url 'category' category.pk %}" class="list-group-item">{{ category.name }}<span class="badge">{{ category.num_posts }}</span></a>
                            {% empty %}
                            <a class="list-group-item">暂无分类</a>
                            {% endfor %}
                        </div>
                    </div>
                </div>

                <div class="widget widget-tag-category">
                  <div class="panel panel-info">
                    <div class="panel-heading">
                      <h3 class="panel-title">标签云</h3>
                    </div>
                    <div class="panel-body">
                        {% get_tags as tag_list %}
                        <ul class="nav nav-pills" role="tablist">
                        {% for tag in tag_list %}
                            <li role="presentation"><a href="{% url 'tags' tag.pk %}">{{ tag.name }}</a></li>
                        {% empty %}
                        <a class="list-group-item">暂无标签</a>
                        {% endfor %}
                        </ul>
                    </div>
                </div>
            </aside>
        </div>
    </div>
</div>
{% endblock %}

{% block js_extras %}
<script type="text/javascript">
    $('#index').addClass('active');
</script>
{% endblock %}